package bookManageSystem.view;

import java.awt.*;
import java.util.ArrayList;

public class DoctorListApp {

    public static void main(String[] args) {
        // 创建一个Frame
        Frame frame = new Frame("Doctor List");
        frame.setSize(400, 300);
        frame.setLayout(new BorderLayout());

        // 创建一个List来显示医生信息
        List doctorList = new List();

        // 创建一些Doctor对象
        ArrayList<Doctor> doctors = new ArrayList<>();
        doctors.add(new Doctor(1, "Alice Smith", "Female", 45, "Cardiologist", "Specialized in heart diseases", "Mon-Fri 9-5"));
        doctors.add(new Doctor(2, "Bob Johnson", "Male", 50, "Neurologist", "Expert in nervous system disorders", "Tue-Thu 10-6"));
        doctors.add(new Doctor(3, "Charlie Brown", "Male", 38, "Pediatrician", "Cares for children's health", "Mon-Wed 8-4"));

        // 将Doctor对象添加到List中
        for (Doctor doctor : doctors) {
            doctorList.addItem(doctor.toString()); // 假设Doctor类有一个toString()方法
        }

        // 将List添加到Frame中
        frame.add(doctorList, BorderLayout.CENTER);

        // 设置Frame的关闭操作
        frame.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent windowEvent) {
                frame.dispose();
            }
        });

        // 显示Frame
        frame.setVisible(true);
    }
}

class Doctor {
    private int doctorId;
    private String name;
    private String gender;
    private int age;
    private String position;
    private String description;
    private String schedule;

    public Doctor(int doctorId, String name, String gender, int age, String position, String description, String schedule) {
        this.doctorId = doctorId;
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.position = position;
        this.description = description;
        this.schedule = schedule;
    }

    @Override
    public String toString() {
        return "ID: " + doctorId + ", Name: " + name + ", Position: " + position;
    }
}
